import { createApp } from "vue";
import { createRouter, createWebHistory } from "vue-router";
import Home from "./views/Home.vue";
import Login from "./views/Login.vue";
import ColumnDetail from "./views/ColumnDetail.vue";
import App from "./App.vue";
import store from "./store";
import axios from "axios";

axios.defaults.baseURL = "http://apis.imooc.com/api/";
axios.interceptors.request.use(config => {
  config.params = { ...config.params, icode: "C6A6C4086133360B" };
  return config;
});
axios.get("/columns", { params: { key: "hello" } }).then(resp => {
  console.log(resp.data);
});

const routerHistory = createWebHistory();
const router = createRouter({
  history: routerHistory,
  routes: [
    {
      path: "/",
      name: "home",
      component: Home
    },
    {
      path: "/login",
      name: "login",
      component: Login
    },
    {
      path: "/column/:id",
      name: "column",
      component: ColumnDetail
    }
  ]
});

const app = createApp(App);
app.use(router);
app.use(store);
app.mount("#app");
